package com.danhar.forward.util;

/**
 * 钉钉错误码枚举
 * @author hu
 * @version 1.0
 * @date 2020/6/30/030
 */
public enum errorCodeEnum {

    INTERNAL_GATEWAY_ERROR(100,"网关内部发生错误，详情参考Code字段说明"), //
    NO_ACCESS(1006,"当前用户没有访问该应用的权限"), //
    PASSWORD_EXPIRE(1016,"您的密码已过期，请重置密码后使用新密码登录"), //
    INVALID_PARAMETER(1019,"无效的参数（比如不允许为空的参数空了"), //
    REQUEST_EXPIRED(1020,"请求已过期"), //
    SIGNATURE_VERIFICATION_FAILURE(1021,"签名验证失败"), //
    APPCODE_ILLEGAL(1200,"APPCODE非法"), //
    VALIDATEACCESSTOKEN_ENMPTY(1205,"请求VALIDATEACCESSTOKEN时参数为空"), //
    ACCESSTOKEN_INVALID(1206,"ACCESSTOKEN无效"), //
    ACCESSTOKEN_EXPIRED(1207,"ACCESSTOKEN过期"), // NO_ACCESS(1006,"当前用户没有访问该应用的权限"), //
    NO_USERPROFILE_BY_ACCESSTOKEN(1208,"根据ACCESSTOKEN取不到USERPROFILE信息"), //
    GET_ACCESSTOKEN_IS_NOT_AUTHORIZED_IN_A_PROTECTED_API(1209,"获取ACCESSTOKEN的授权方式未在受保护的API中进行授权"), //
    GET_ACCESSTOKEN_IS_TOO_LOW(1210,"获取ACCESSTOKEN的授权方式低于API保护的授权"), //
    INVALID_CLIENT_TYPE(1211,"无效的客户端类型"), //
    REFRESH_ACCESSTOKEN_FAILURE(1220,"刷新ACCESSTOKEN失败，ACCESSTOKEN已经被更新"), //
    APPLICATION_INFORMATION_IS_INACCURATE(1222,"应用信息不准确，ACCESSTOKEN不是当前应用生成"), //
    APPCODE_AND_TOKEN_ASSOCIATED_WITH_DIFFERENT(1230,"APPCODE和TOKEN关联的不相同"), //


    ;

    private Integer code ;
    private String name ;

    public Integer getCode() {
        return code;
    }


    public void setCode(Integer code) {
        this.code = code;
    }


    public String getName() {
        return name;
    }


    public void setName(String name) {
        this.name = name;
    }


    errorCodeEnum(Integer code , String name ){
        this.code = code ;
        this.name = name;
    }

    public static errorCodeEnum getByCode(Integer code) {
        for(errorCodeEnum tmpEnum : values() ){
            if(tmpEnum.getCode() .equals(code)){
                return tmpEnum ;
            }
        }
        return null ;
    }

    public boolean isCodeValid(Integer code){
        for(errorCodeEnum tmpEnum : values() ){
            if(tmpEnum.getCode().equals(code) ){
                return true ;
            }
        }
        return false ;
    }

}
